package com.hy.erp.inventory.service;

import java.util.List ;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

/*import javax.ejb.Stateless ;

import org.jboss.seam.ScopeType ;
import org.jboss.seam.annotations.Name ;
import org.jboss.seam.annotations.Scope ;
import org.jboss.seam.async.Schedule ;*/

import com.hy.enterprise.architecture.foundation.ArchitectureFoundationException;
import com.hy.enterprise.framework.service.business.AbstractBusinessService;
import com.hy.erp.inventory.dao.ProvinceDao;
import com.hy.erp.inventory.dao.interfaces.IProvinceDao;
import com.hy.erp.inventory.dao.interfaces.IUserDao;
import com.hy.erp.inventory.pojo.Province;
import com.hy.erp.inventory.pojo.interfaces.IProvince;
import com.hy.erp.inventory.pojo.interfaces.IUser;
import com.hy.erp.inventory.service.interfaces.IProvinceService;

/**
 * 
 * <ul>
 * <li>开发作者：汤莉</li>
 * <li>设计日期：2010-10-13；时间：上午10:59:41</li>
 * <li>类型名称：ProvinceService</li>
 * <li>设计目的：</li>
 * </ul>
 * <ul>
 * <b>修订编号：</b>
 * <li>修订日期：</li>
 * <li>修订作者：</li>
 * <li>修订原因：</li>
 * <li>修订内容：</li>
 * </ul>
 */
/*@Name("provinceService")
@ Scope ( ScopeType.STATELESS )
@ Stateless*/
@Component("provinceService")

public class ProvinceService
							extends
							AbstractBusinessService <ProvinceDao>
																	implements
																	IProvinceService
{

	/**
	 * <ul>
	 * <li>开发作者：汤莉</li>
	 * <li>设计日期：2010-10-13；时间：上午10:59:59</li>
	 * <li>字段类型：long；字段名称：serialVersionUID</li>
	 * <li>设计目的：</li>
	 * </ul>
	 * <ul>
	 * <b>修订编号：</b>
	 * <li>修订日期：</li>
	 * <li>修订作者：</li>
	 * <li>修订原因：</li>
	 * <li>修订内容：</li>
	 * </ul>
	 */
	private static final long	serialVersionUID	=
														- 258805654422317920L ;

	
	private ProvinceDao provinceDao=null;
	
	

	@Resource(name="provinceDao")
	public void setPositionTypeDao(ProvinceDao provinceDao) {
		this.provinceDao = provinceDao;
	}
	/**
	 * 
	 * 构造函数
	 */
	public ProvinceService()
	{
		super ( );
	}
	
	@ Override
	public boolean addProvince (
									Province province )
	{
		if(province==null)
		{
			return true;
		}
		else
		{
			//IProvinceDao dao=( IProvinceDao ) this.getDao ( IProvince.class );
			//IProvince iProvince=province;
			return provinceDao.persist ( province ) ;
		}
	}

	@ Override
	public Integer removeProvince (
									String [ ] provinceIds )
	{
		if ( ( null == provinceIds )
			     || ( provinceIds.length == 0 ) )
			{
				return new Integer (
				                     0 ) ;
			}
			else
			{
				//IProvinceDao dao=( IProvinceDao ) this.getDao ( IProvince.class );
				return provinceDao.remove ( provinceIds );
			}
	}

	@ SuppressWarnings ( "unused" )
	@ Override
	public boolean modifyProvince (
									Province province )
	{
		if ( ( null == province ) || ( null == province.getIdentifier ( ) ))
		{
			return true;
		}
		else
		{
			//IProvinceDao dao=( IProvinceDao ) this.getDao ( IProvince.class );
			//IProvince iProvince=province;
			
			if ( null == province )
			{
				throw new ArchitectureFoundationException (
				                                            "修改用户实体数据时发生错误，所需要修改的实体在数据库中并不存在" ) ;
			}
			return (provinceDao.merge ( province )!=null) ;
		}
		
	}

	@ Override
	public String [ ] addProvince (
									Object [ ] objects )
	{
		//IProvinceDao dao=( IProvinceDao ) this.getDao ( IProvince.class );
		Province[] provinces=new Province[objects.length];
		for ( int i =
						0 ; i < objects.length ; i ++ )
		{
			Province province=( Province ) objects[i];
			provinces[i]=province;
		}
		return provinceDao.persist ( provinces ) ;
	}

	@ Override
	public List < Province > getAllProvince ( )
	{
		//IProvinceDao dao=( IProvinceDao ) this.getDao ( IProvince.class );
		return provinceDao.find ( ) ;
	}

	@ Override
	public String [ ] modifyProvince (
										Object [ ] objects )
	{
		if (  null == objects ) 
		{
			return null;
		}
		else
		{
			//IProvinceDao dao=( IProvinceDao ) this.getDao ( IProvince.class );
			Province[] types=new Province[objects.length];
            for(int i=0;i<objects.length;i++)
            {
            	Province type=( Province ) objects[i];
            	types[i]=type;
            }
			
			return provinceDao.merge ( types );
		}
	}
	@Override
	public Province findProvinceById(String id) {
		return provinceDao.findByIdentifier(id);
	}

}
